Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Fix autoloading when addon has multiple service providers #11128

Merged
merged 7 commits into from
Dec 17, 2024

Conversation

duncanmcclean
Copy link
Member

This pull request changes the "base path" used when autoloading addon components, to prevent addons with multiple service providers from booting the same stuff multiple times.

Fixes #11082.

@jasonvarga
Copy link
Member

I've pushed up some changes so that "root level items" like config, routes, views, blueprints, etc will only get booted by the root provider.

I added handling so that if you have multiple providers at the root level, the root level items only get booted once.

So, now nested providers can have autoloadable things relative to them like tags, actions, etc.

|-- src
|   |-- Tags
|       |-- TagOne.php
|   |-- ServiceProvider.php             <-- this will load TagOne, routes, config, lang, views
|   |-- AnotherServiceProvider.php      <-- this will only load stuff inside its $tags/$fieldtypes/etc properties
|   |-- Modules
|       |-- Something
|           |-- Tags
|           |   |-- AnotherTag.php
|           |-- ServiceProvider.php     <-- this will load AnotherTag, but not routes/config/lang/views
|-- routes
|   |-- web.php
|-- config
|   |-- addon.php 
|-- resources
    |-- lang
    |-- views

@jasonvarga jasonvarga requested a review from edalzell December 13, 2024 21:42
Copy link
Contributor

@edalzell edalzell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave this a try and my "nested" routes aren't loading.

I have routes like so:

image image

And the Stripe ones aren't loaded.

I haven't checked the configs/blueprints yet.

@jasonvarga jasonvarga merged commit ae98dff into 5.x Dec 17, 2024
19 checks passed
@jasonvarga jasonvarga deleted the fix/autoloading-when-addon-has-multiple-providers branch December 17, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Addon update called many times
3 participants